/**
 * 统计图表
 * */


// 跳转
function toJump(){
    var year_id = $('#year_id').val();
    var month_id = $('#month_id').val();
    var p = '?year_id=' + year_id;
    p += '&month_id=' + month_id;
    window.location.href = 'person.html' + p;
}


// 选择
function getOption(){
    var h = '', i;
    //年份
    // if (year_id == 0) {
    //     h = '<option value="0" selected>选择</option>';
    // } else {
    //     h = '<option value="0">选择</option>';
    // }
    h = '';
    for (i = 1980; i <= 2100; i ++) {
        if (year_id == i) {
            h += '<option value="' + i + '" selected>';
        } else {
            h += '<option value="' + i + '">';
        }
        h += i + '年';
        h += '</option>';
    }
    $('#year_id').html(h);
    //月份
    if (month_id == 0) {
        h = '<option value="0" selected>选择</option>';
    } else {
        h = '<option value="0">选择</option>';
    }
    for (i = 1; i <= 12; i ++) {
        if (month_id == i) {
            h += '<option value="' + i + '" selected>';
        } else {
            h += '<option value="' + i + '">';
        }
        h += i + '月';
        h += '</option>';
    }
    $('#month_id').html(h);
}


//列表
function getList(){
    var uinfo = getUserInfo();
    var formData = {
        uid: uinfo.uid, 
        year_id: year_id, month_id: month_id,
    };
    $.ajax({
        type: apiMethod,
        url: apiDomain + 'tongji/person',
        data: formData,
        success: function (res) {
            console.log(res);
            if (res.code != 0) {
                msgPop({msg: res.msg});
                return
            }
            getHtml(res.data);
        },
        error: function () {
            console.log('网络错误');
        }
    });
}
function getHtml(d){
    var h = '', i;
    h = '';
    for (i = 0; i < d.length; i ++) {
        h += '<table cellspacing="0">';
        h += '<tr>';
        h += '<td class="tdl">录入时间</td>';
        h += '<td>';
        h += d[i].in_day;
        h += '</td>';
        h += '</tr>';
        h += '<tr>';
        h += '<td class="tdl">部门</td>';
        h += '<td>';
        h += d[i].depart_name;
        h += '</td>';
        h += '</tr>';
        h += '<tr>';
        h += '<td class="tdl">员工</td>';
        h += '<td>';
        h += d[i].uname;
        h += '</td>';
        h += '</tr>';
        h += '<tr>';
        h += '<td class="tdl">项目</td>';
        h += '<td>';
        h += d[i].item_name;
        h += '</td>';
        h += '</tr>';
        h += '<tr>';
        h += '<td class="tdl">合计时长</td>';
        h += '<td>';
        h += d[i].delay;
        h += '</td>';
        h += '</tr>';
        h += '</table>';
    }
    $('.tlist').html(h);
}